package com.hhit.bigscreenbackmanage.controller.aqgl;

import cn.hutool.core.map.MapUtil;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.service.aqgl.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName AqglFxCountController
 * @Description
 * @Author qianchengcheng
 * @Date 2021/7/21
 */
@RestController
@RequestMapping("/aqgl")
public class AqglImportController {

    private static Logger log = LoggerFactory.getLogger(AqglImportController.class);

    @Autowired
    private AqglFxCountService aqglFxCountService;

    @Autowired
    private AqglFxService aqglFxService;

    @Autowired
    private AqglRbService aqglRbService;

    @Autowired
    private AqglKqrsService aqglKqrsService;

    @Autowired
    private AqglKqrsDxgcService aqglKqrsDxgcService;

    @Autowired
    private AqglRybzService aqglRybzService;

    @Autowired
    private AqglZypTjService aqglZypTjService;

    @Autowired
    private AqglZypXqService aqglZypXqService;

    @Autowired
    private AqglDrrygkTempService aqglDrrygkTempService;

    @Autowired
    private AqglDailyPaperTempService aqglDailyPaperTempService;

    @Autowired
    private AqglJdjcqkService aqglJdjcqkService;

    @Autowired
    private AqglJdjcqkSblzService aqglJdjcqkSblzService;

    @Autowired
    private AqglJdjcqkYcjcService aqglJdjcqkYcjcService;

    /**
     * @Description:
     * @Author: qianchengcheng 
     * @Date: 2021/7/22 10:40
     * @Param: [propName, files] 
     * @Return: com.hhit.bigscreenbackmanage.common.Response
     **/
    @PostMapping("/importExcel")
    public Response importAgqlExcel(String propName, MultipartFile[] files,String datetime){
        try {
            Map<String,Object> importResMap = new HashMap<>();
            if ("aqglFxzysltjColumnName".equals(propName)){
                importResMap = aqglFxCountService.importAgqlFxCount(propName,files,datetime);
            }
            if ("aqglFxtjxqColumnName".equals(propName)){
                importResMap = aqglFxService.importAgqlFx(propName,files,datetime);
            }
            if ("aqglRbColumnName".equals(propName)){
                importResMap = aqglRbService.importAgqlRb(propName,files,datetime);
            }
            if ("aqglKqrsColumnName".equals(propName)){
                importResMap = aqglKqrsService.importAqglKqrs(propName,files,datetime);
            }
            if ("aqglDxgcKqrsColumnName".equals(propName)){
                importResMap = aqglKqrsDxgcService.importAqglKqrsDxgc(propName,files,datetime);
            }
            if ("aqglRybzColumnName".equals(propName)){
                importResMap = aqglRybzService.importAqglRybz(propName,files,datetime);
            }
            if ("aqglZypsltjColumnName".equals(propName)){
                importResMap = aqglZypTjService.importAqglZypTj(propName,files,datetime);
            }
            if ("aqglZyptjxqColumnName".equals(propName)){
                importResMap = aqglZypXqService.importAqglZypXq(propName,files,datetime);
            }
            if ("aqglDrrygkColumnName".equals(propName)){
                importResMap = aqglDrrygkTempService.importAqglDrrygkTemp(propName,files,datetime);
            }
            if ("aqglDailyPaperColumnName".equals(propName)){
                importResMap = aqglDailyPaperTempService.importAqglDailyPaperTemp(propName,files,datetime);
            }
            if ("aqglJdjcqkColumnName".equals(propName)){
                importResMap = aqglJdjcqkService.importAqglJdjcqk(propName,files,datetime);
            }
            if ("aqglJdjcqkSblzColumnName".equals(propName)){
                importResMap = aqglJdjcqkSblzService.importAqglJdjcqkSblz(propName,files,datetime);
            }
            if ("aqglJdjcqkYcjcColumnName".equals(propName)){
                importResMap = aqglJdjcqkYcjcService.importAqglJdjcqkYcjc(propName,files,datetime);
            }
            boolean importRes = Boolean.valueOf(MapUtil.getStr(importResMap,"flag"));
            if (importRes){
                return Response.createResponseBySuccess("导入成功");
            }else {
                return Response.createResponseByError("导入失败");
            }
        }catch (Exception e){
            log.error("AqglImportController.importAgqlExcel Call error",e);
            return Response.createResponseByError("导入异常:"+e.getMessage());
        }
    }
}
